package cn.doitedu.day03

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/*
 * repartition一定shuffle，底层调用的就是coalesce方法
 */
object T06_CoalesceDemo {

  def main(args: Array[String]): Unit = {

    //1.创建SparkConf
    val conf = new SparkConf().setAppName("repartition")
      .setMaster("local[4]")
    val sc = new SparkContext(conf)

    val rdd1 = sc.parallelize(List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 3)

    //val rdd11: RDD[Int] = rdd1.repartition(4)
    //shuffle = true

    //val rdd2 = rdd1.coalesce(3, true)
    //与repartition(3)功能一样

    val rdd22 = rdd1.coalesce(2, false)
  }
}
